<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>登录</title>
	<link rel="stylesheet" href="<{:STATICS}>/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="<{:STATICS}>/font-awesome/css/font-awesome.min.css">
	<link rel="stylesheet" href="<{:STATICS}>/iealert/style.css">
	<link rel="stylesheet" href="<{:RES}>/css/login.css" />
	<script type="text/javascript" src="<{:STATICS}>/js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="<{:STATICS}>/js/jquery.form.min.js"></script>
	<script type="text/javascript" src="<{:STATICS}>/layui/lay/dest/layui.all.js"></script>
	<script type="text/javascript" src="<{:STATICS}>/iealert/iealert.js"></script>
	<script type="text/javascript" src="<{:RES}>/js/common.js"></script>
</head>
<body class="beg-login-bg">
	<div class="beg-login-box">
		<header>
			<h1>后台登录</h1>
		</header>
		<div class="beg-login-main">
			<form id="ajaxForm" action="<{:U('Login/checkLogin')}>" class="layui-form" method="post">
				<div class="layui-form-item">
					<label class="beg-login-icon">
                        <i class="layui-icon">&#xe612;</i>
                    </label>
					<input type="text" name="username" lay-verify="required" autocomplete="off" placeholder="请输入登录名" class="layui-input">
				</div>
				<div class="layui-form-item">
					<label class="beg-login-icon">
                        <i class="layui-icon">&#xe642;</i>
                    </label>
					<input type="password" name="password" lay-verify="required" autocomplete="off" placeholder="请输入密码" class="layui-input">
				</div>
				<div class="layui-form-item">
					<label class="beg-login-icon">
                        <i class="layui-icon">&#xe64a;</i>
                    </label>
					<input type="text" name="checkcode" id="checkcode" lay-verify="required" autocomplete="off" placeholder="请输入验证码" class="layui-input">
				</div>
				<div class="layui-form-item">
					<div class="beg-pull-left beg-login-remember">
						<img id="verifyImg" SRC="<{:U('Login/verify')}>" onClick="fleshVerify()" style="cursor:pointer" align="absmiddle" />
					</div>
					<div class="beg-pull-right">
						<button class="layui-btn layui-btn-primary" lay-submit lay-filter="submitBtn">
                        <i class="layui-icon">&#xe650;</i> 登录
                    </button>
					</div>
					<div class="beg-clear"></div>
				</div>
			</form>
		</div>
		<footer>
			<p>Designer © 20779512</p>
		</footer>
	</div>
</body>
</html>
<script type="text/javascript">
$(function(){
	$("body").iealert();
});

$(function(){
	//ajaxform
	var options = { 
		dataType:'json',
		beforeSubmit:showRequest,//表单验证方式
        success:showResponse  // post-submit callback 
    }; 
    $('#ajaxForm').ajaxForm(options); 
    function showResponse(responseText, statusText)  {
    	$('#ajaxForm button').removeAttr('disabled');
    	$('#ajaxForm input').removeAttr('disabled');
		if (statusText == 'success') {
			parent.layer.close(load);
			if (responseText.status==1) {
				parent.layer.open({
					type:0, 
					icon:1,
					content:responseText.info,
					time:3000,
					end: function(){ 
						if(responseText.url!='' && responseText.url!=undefined && responseText.url!="undefined"){
							if (responseText.url=='reload') {
								window.location.reload();
							}else{
								window.location.href = responseText.url;
							}									
						}
					} 
				});
			}else{
				parent.layer.open({
					type:0, 
					icon:2,
					content:responseText.info
				});
				$("#verifyImg").click();
				$("#checkcode").val("");
			}
		}else{
			parent.layer.msg('服务器错误');
		}
	} 

	function showRequest(){
		$('#ajaxForm button').attr("disabled","disabled");
		$('#ajaxForm input').attr("disabled","disabled");
		load = parent.layer.load(0,{shade: [0.7, '#000000']});
	}
})
</script>